package com.shigen.demo.controller;

import com.shigen.demo.dao.UserMapper;
import com.shigen.demo.entity.User;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 缓存控制类
 *
 * @author shigenfu
 * @date 2022/6/18 9:29 下午
 */
@RestController
@RequestMapping(value = "cache")
public class CacheController {

  @Resource
  private UserMapper userMapper;

  /**
   * 用户信息缓存
   */
  @Cacheable(value = {"userinfo"}, key = "'userinfo'")
  @GetMapping(value = "saveuser")
  public List<User> userList() {
    return userMapper.selectList(null);
  }
}
